﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Architecture.Linq;
using System.ComponentModel;

namespace Emerald.Business.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    public class RoleController : GenericController<Role, EmeraldDataContext>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="roleName"></param>
        /// <returns></returns>
        [DataObjectMethod(DataObjectMethodType.Select)]
        public Role GetRoleByRoleName(string roleName)
        {
            #region Validation
            if (String.IsNullOrEmpty(roleName))
            {
                throw new ArgumentNullException("roleName");
            }
            #endregion

            Role result = (from role in EntityTable
                           where role.RoleName == roleName
                           select role).SingleOrDefault();

            return result;
        }
    }
}
